package com.heo.music.player.controller;

import com.heo.music.player.dto.input.MusicInfoInput;
import com.heo.music.player.dto.output.MusicInfoOutput;
import com.heo.music.player.dto.output.PageOutput;
import com.heo.music.player.dto.query.MusicInfoQuery;
import com.heo.music.player.service.MusicInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.io.IOException;

/**
 * created on 2024-05-11 09:24
 *
 * @author 星天无极
 **/
@Api(tags = "音乐信息管理接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1")
public class MusicInfoController {

    private final MusicInfoService musicInfoService;

    @ApiOperation("查找音乐信息")
    @GetMapping("/musicInfo")
    public PageOutput<MusicInfoOutput> findAllMusicInfo(@Valid MusicInfoQuery query) {
        return musicInfoService.findAllMusicInfo(query);
    }

    @ApiOperation("新增音乐信息")
    @PostMapping("/musicInfo")
    public MusicInfoOutput createMusicInfo(@Valid @RequestBody MusicInfoInput input) throws IOException {
        return musicInfoService.createMusicInfo(input);
    }

    @ApiOperation(("删除音乐信息"))
    @DeleteMapping("/musicInfo/{id}")
    public void deleteMusicInfo(@PathVariable Integer id) {
        musicInfoService.deleteMusicInfo(id);
    }

}
